package cn.com.wdjedu.androidapp.wjeduandroid.mvp.main;


import java.util.Map;

import cn.com.wdjedu.androidapp.wjeduandroid.support.lib.mvputils.BasePresenter;
import cn.com.wdjedu.androidapp.wjeduandroid.support.lib.mvputils.RxSubscribe;
import cn.com.wdjedu.androidapp.wjeduandroid.ui.mainfragment.MainBean;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;


public class MainPresenter extends BasePresenter<Mainview> {

    private MainDao mainDao;

    public MainPresenter(Mainview view) {
        mainDao=new MainDao();
    }

    public void queryMainData(Map<String,String> maps){
        mView.showLoading();
        subscription=mainDao.queryMainData(maps)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new RxSubscribe<MainBean>() {
                    @Override
                    public void _onNext(MainBean mainBean) {
                        if (mView!=null){
                            mView.queryNewMainData(mainBean);
                        }
                    }

                    @Override
                    public void _onError(String message) {
                        showError(message);
                    }
                });
    }


}
